<template>
  <div style="padding=20px" class="app-container">
    <el-form >
      <el-form-item label="信息说明">
        <el-tag>excel模板说明</el-tag>
        <el-tag>
          <i class="el-icon-download"/>
        <a :href="defaultExcelTemplate">点击下载模板</a></el-tag>
      </el-form-item>
      <el-form-item label="选择Excel文件">
        <el-upload
          ref="upload"
          :on-success="handleSuccess"
          :auto-upload="false"
          :action="uploadURL"
          class="upload-demo">
          <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
          <el-button :disabled="flag" style="margin-left: 10px;" size="small" type="success" @click="submitUpload">导入</el-button>
        </el-upload>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  data() {
    return {
      defaultExcelTemplate: 'https://guli-java0625.oss-cn-shanghai.aliyuncs.com/excel-module/2021/11/02/85a01574-bf3c-4702-b052-e7a0d3330938.xls',
      uploadURL: 'http://localhost:9110/admin/edu/subject/import',
      flag: false
    }
  }, methods: {
    submitUpload() {
      this.flag = true
      this.$refs.upload.submit()
    },
    handleSuccess(res) {
      this.flag = false
      this.$refs.upload.clearFiles()
      this.$message.success('上传成功')
    }

  }
}
</script>
